﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Web;
using Platform.Permission;

namespace Entity
{
    [Serializable]
    public class LoginInfo
    {
        private string _IP = string.Empty;
        /// <summary>
        /// 用户登陆IP
        /// </summary>
        public string IP
        {
            get
            {
                return HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
            }

        }



        /// <summary>
        /// 用户账号，登录账号
        /// </summary>
        public string Account
        {
            get
            {
                return LoginHelper.Account;
            }

        }


        //工号
        private string _StaffNo = string.Empty;
        /// <summary>
        ///工号 
        /// </summary>
        public string StaffNo
        {
            get
            {
                return _StaffNo;
            }
            set
            {
                _StaffNo = value;
            }
        }



        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName
        {
            get
            {
                return LoginHelper.Name;
            }

        }

        /// <summary>
        /// 密码
        /// </summary>
        public string PWS
        {
            get
            {
                return LoginHelper.PWS;
            }

        }



        /// <summary>
        /// 用户ID
        /// </summary>
        public int UserID
        {
            get
            {
                return LoginHelper.UserID;

            }

        }

        /// <summary>
        /// 电子签名路径
        /// </summary>
        public string ElectronSign
        {
            set
            {
                HttpContext.Current.Session["ElectronSign"] = value;       
            }
            get
            {
                return Convert.ToString(HttpContext.Current.Session["ElectronSign"]);
            }
        }


        private static LoginInfo _CurrentUser = null;

        //应用单件模式，保存用户登录状态
        public static LoginInfo CurrentUser
        {
            get
            {
                if (_CurrentUser == null)
                    _CurrentUser = new LoginInfo();
                return _CurrentUser;

            }

        }

    }
}
